package com.mywang.weitravel.modules.home;

import com.mywang.weitravel.base.BasePresenter;
import com.mywang.weitravel.model.HomeListBean;
import com.mywang.weitravel.net.RetrofitHelper;
import com.mywang.weitravel.net.RxSchedulers;
import com.mywang.weitravel.net.VObserver;

import java.util.List;

/**
 * Created by wangmingyun on 2019/12/5.
 */
public class HomePresenter extends BasePresenter<HomeContract.View> implements HomeContract.Presenter {

    public HomePresenter(HomeContract.View view) {
        super(view);
    }

    @Override
    public void getHomeList() {
        RetrofitHelper.getInstance().getServer()
                .getHomeList()
                .compose(RxSchedulers.applySchedulers())
                .as(bindToLife())
                .subscribe(new VObserver<List<HomeListBean>>() {
                    @Override
                    protected void onSuccess(List<HomeListBean> testBeans) {
                        mView.setBook(testBeans);
                    }
                });
    }
}
